<template>
  <el-form ref="user" :model="user" :rules="rules" label-width="80px">
    <el-form-item label="姓名" prop="name">
      <el-input v-model="user.name" />
    </el-form-item>
    <el-form-item label="部门编号" prop="dept_id">
      <el-input v-model="user.dept_id" />
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.sex">
        <el-radio label="0">男</el-radio>
        <el-radio label="1">女</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" size="mini" @click="submit">保存</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import { updateUserProfile } from '@/api/user'
import { Message } from 'element-ui'

export default {
  data() {
    return {
      user: {
        name: '',
        sex: undefined,
        dept_id: undefined
      }
    }
  },
  methods: {
    submit() {
      updateUserProfile(this.user).then(response => {
        Message({
          message: '修改成功',
          type: 'success',
          duration: 5 * 1000
        })
      })
    }
  }
}
</script>
